home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / XML Utilities / Professional Programmer XSL IDE / Xselerator25.msi / Data.Cab / F47260_xsStrCompare2.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2001-07-22  |  1.4 KB  |  54 lines

  1. <xsl:stylesheet version='1.0'
  2. xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
  3. >
  4.  
  5. <xsl:output method="text"/>
  6.  
  7. <xsl:template match="/">
  8.   <xsl:variable name="node1" select="/cities/city[3]"/>
  9.   <xsl:variable name="node2" select="/cities/city[2]"/>
  10.  
  11.   <xsl:text>"</xsl:text>
  12.   <xsl:value-of select="$node1"/>
  13.   <xsl:text>"</xsl:text>
  14.   <xsl:text> is</xsl:text>
  15.     
  16.   <xsl:call-template name="node-stringCompare">
  17.     <xsl:with-param name="node1" select="$node1"/>
  18.     <xsl:with-param name="node2" select="$node2"/>
  19.   </xsl:call-template>
  20.     
  21.     <xsl:text>"</xsl:text>
  22.     <xsl:value-of select="$node2"/>
  23.     <xsl:text>"</xsl:text>
  24. </xsl:template>
  25.  
  26. <xsl:template name="node-stringCompare">
  27.   <xsl:param name="node1"/>
  28.   <xsl:param name="node2"/>
  29.     
  30.   <xsl:choose>
  31.     <xsl:when test="string($node1)=string($node2)">
  32.       <xsl:text> equal to </xsl:text>
  33.     </xsl:when>
  34.     <xsl:otherwise>
  35.       <xsl:for-each select="$node1 | $node2">
  36.         <xsl:sort select="."/>
  37.  
  38.         <xsl:if test="position()=1">
  39.           <xsl:choose>
  40.             <xsl:when test="string(.) = string($node1)">
  41.               <xsl:text> less than </xsl:text>
  42.             </xsl:when>
  43.             <xsl:otherwise>
  44.               <xsl:text> greater than </xsl:text>
  45.             </xsl:otherwise>
  46.           </xsl:choose>
  47.         </xsl:if>
  48.       </xsl:for-each>
  49.     </xsl:otherwise>
  50.   </xsl:choose>
  51.     
  52. </xsl:template>
  53. </xsl:stylesheet>
  54.